<?php
include_once("../configure/admin.config.inc.php");	//--> admin global var
include_once("db.inc.php");							//--> db global var
include_once("Smarty.class.php");					//--> out template
include_once("Operation.php");						//--> Operation
require_once("controlHeader.php");					//--> system control header

$objOperate		= new Operation($sessionImpl->getLanguage());		//--> Operation instance

$error_message 		= '';

$arrOperate = $objOperate->arrGetFromGroupIDAndMenuID($gid, $menuid);
if(!empty($id)){
	$arrInfo = $objOperate->getFromID($arrOperate, $id);
	
	$name 	= $arrInfo['name'];
}

if(isset($_POST['Submit'])){
	$name 	= $_POST['name'];
	
	if(empty($name)){
		$error_message = 'The operation name should\'t be empty.';
	}
	
	if(empty($error_message)){
		$isReturn = $objOperate->edit($arrOperate, $id, $name);
		if($isReturn)
			$error_message = 'edit successfully.';
		else 
			$error_message = 'edit failure.';
	}
}

/*----- out html -----*/
$smarty = new Smarty();					//----- out template
$smarty->template_dir = TEMPLATE_SYS_DIR;
$smarty->compile_dir  = CACHE_SYS_DIR;
$smarty->assign('menuGid', $menuGid);
$smarty->assign('menuid', $menuid);
$smarty->assign('id', $id);

$smarty->assign('backurl',$backurl);
$smarty->assign('error_message', $error_message);

$smarty->assign('name', $name);

$smarty->display('listOperation_Edit.htm');
?>
